//
//  XLViewController.m
//  OpenCoreAmrCodec
//
//  Created by ilongge on 04/02/2024.
//  Copyright (c) 2024 ilongge. All rights reserved.
//

#import "XLViewController.h"
#import "OpenCoreAmrCodec.h"
@interface XLViewController ()

@end

@implementation XLViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}

- (IBAction)encodeWaveToAmrAction:(id)sender {
    NSString *waveFilePath = [[NSBundle mainBundle] pathForResource:@"白龙马" ofType:@"wav"];
    NSString *amrFilePath = [NSString stringWithFormat:@"%@/Documents/白龙马.amr", NSHomeDirectory()];
    [OpenCoreAmrCodec encodeWaveFile:waveFilePath
                             amrFile:amrFilePath
                            channels:1
                       bitsPerSample:16];
    NSLog(@"%@", amrFilePath);
}

- (IBAction)decodeAmrToWaveAction:(id)sender {
    NSString *amrFilePath = [[NSBundle mainBundle] pathForResource:@"白龙马" ofType:@"amr"];
    NSString *waveFilePath = [NSString stringWithFormat:@"%@/Documents/白龙马.wav", NSHomeDirectory()];
    [OpenCoreAmrCodec decodeAmrFile:amrFilePath
                           waveFile:waveFilePath];
    NSLog(@"%@", waveFilePath);
}

@end
